package cn.tedu.online.day05;

import java.util.Arrays;

public class SelectionSort {
    public static void main(String[] args) {
        int[] ary = {23,12,5,56};
        //升序排列
        for (int i=0;i<ary.length-1;i++){
            int min = i;
            for (int j=i+1;j<ary.length;j++){
                if (ary[j]<ary[min]){
                    min=j;
                }
            }
            //将min位置和i位置的值互换
            int tmp = ary[i];
            ary[i] =ary[min];
            ary[min] =tmp;
        }
        System.out.println(Arrays.toString(ary));
    }
}
